#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define char2number(x)(x-'0')  //char to int

int string2int(char s[]){
    int length = strlen(s);
    printf("string length: %d \n", length);
    int ret=0, num=0;
    for(int i=0; i<length; i++){
        num = char2number(*(s+i));
        printf("%d \n", num);
        ret = ret + num*pow(10, length-1-i);
    }
    return ret;
}
int main(void){

    int result=0;
    char s[] = "1234";
    result = string2int(s);
    printf("%d \n", result);

    return 0;
}